﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace WebCollection.Tags
{
    class TXPath
    {
        public string Xpath { get; set; }

        public string Attri { get; set; }

        public string Position { get; set; }

        public TXPath(string xpath, string position)
        {
            this.Xpath = xpath;

            if (xpath.EndsWith("@href"))
            {
                this.Attri = "href";
                return;
            }
            if (xpath.EndsWith("@src"))
            {
                this.Attri = "src";
                return;
            }
            if (xpath.EndsWith("@onclick"))
            {
                this.Attri = "onclick";
                return;
            }
            if (xpath.EndsWith("@title"))
            {
                this.Attri = "title";
                return;
            }

            #region position
            string pos = position.ToLower();
            switch (pos)
            {
                case "outerhtml":
                    this.Position = "outerhtml";
                    return;
                case "innerhtml":
                    this.Position = "innerhtml";
                    return;
                case "innertext":
                    this.Position = "innertext";
                    return;
                default:
                    throw new Exception("position not in (innerhtml,innertext,outerhtml)");
            }
            #endregion
        }
    }
}
